<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>组件配置配置-radiogroup</title>
<{$showjs}>
<link rel="stylesheet" type="text/css" href="../css/main1.css" />
<script language="javascript">
Ext.override(Ext.form.Checkbox, {
  setBoxLabel: function(boxLabel,boxvalue){
    this.boxLabel = boxLabel;
    this.inputValue = boxvalue;
    if(this.rendered){
      this.wrap.child('.x-form-cb-label').update(boxLabel);
    }
  }
});
Ext.onReady(function(){
var myMask = new Ext.LoadMask(Ext.getBody(), {
                        msg: '请稍候...'
                    });



var tabpanel = new Ext.TabPanel({

		activeTab: 0,
		height:300,
		region     : 'center',
		title      : false,
		border	   : false,
		frame	   : true,
		defaults:{bodyStyle:'padding:10px'},
		items      : [{
				title:'静态单选按钮配置',
                layout:'column',
                bbar:['->','-',{
			            text: '添加',
			            handler:function(){
			            	myMask.show();
								var label_ = Ext.getCmp('label').getValue();
								var value_ = Ext.getCmp('value').getValue();
								var radio = new Ext.form.Radio({
										boxLabel: label_,
										name: 'radio',
										inputValue: value_,
										columnWidth:.25,
										listeners:{
											'check':function(radio){
												if(radio.checked){
												var label = radio.boxLabel;
												var value = radio.inputValue;
												Ext.getCmp('label').setValue(label);
												Ext.getCmp('value').setValue(value);
												}
											}
										}
									});
								//var x = radiogroup;
								var radiogroup = Ext.getCmp('fieldset');
								radiogroup.items.add(radio);
								radiogroup.doLayout();
							myMask.hide();
						}
			        },'-',{
			            text: '修改',
			            handler:function(){
			            	myMask.show();
			            		var label_ = Ext.getCmp('label').getValue();
			            		var value_ = Ext.getCmp('value').getValue();
								if(label_!=null){
										Ext.each(Ext.getCmp('fieldset').items.items,function(a,b,c){
											if(a.checked){
												//alert(a.getRawValue() );
												a.setBoxLabel(label_,value_);
												//b.setBoxLabel(value_);
											}
										});
								}else{
									Ext.Msg.alert('提示','请先选择一个！');
								}
							myMask.hide();
						}

			        },'-',{
			            text: '删除',
			            handler:function(){
								Ext.MessageBox.confirm("系统提示","你确认删除当前项目吗?",function(_btn){
									if(_btn=="yes"){
										Ext.each(Ext.getCmp('fieldset').items.items,function(a,b,c){
											if(a.checked){
												this.destroy();
												this.disable();
											}
										});
									}
								});
							}
			        },'-'],
                items:[{
                	border:false,
           			columnWidth:.5,
           			height:100,
           			autoHeight: true,
           			layout:'column',
           			bodyStyle:'padding:10px',
                	items:[
                	{
                		xtype: 'label',
                		text: '标签',
                		cls:'x-form-check-group-label',
                		anchor:'-15'
                	},{
						xtype: 'textfield',
						id:'label',
                        name: 'label',
                        value:'<{$xv}>'
                    }]
                },{
                	border:false,
           			columnWidth:.5,
           			height:100,
           			autoHeight: true,
           			bodyStyle:'padding:10px',
           			layout:'column',
                	items:[{
                		xtype: 'label',
                		text: '值',
                		cls:'x-form-check-group-label',
                		anchor:'-15'
                	},{
						xtype: 'textfield',
						id:'value',
                        name: 'value',
                        value:'<{$yv}>'
                    }]
                	},{
                	id:'fieldset',
                	xtype:'fieldset',
                	title:'预览',
           			columnWidth:1,
           			height:100,
           			autoHeight: true,
           			bodyStyle:'padding:10px',
           			layout:'column'
					<{$items}>
                	}]

		}],
		 buttons: [{
            text: '保存',
            handler:function(){
            	var  x = '';
            	Ext.each(fieldset,function(a,b,c){
            	if(!a.disabled){
            	var check = '';
            		if(a.checked){
						check = '#_#1';
            		}else{
						check = '#_#0';
						}
					x = x  + a.boxLabel+'#_#'+a.inputValue+check+'#=#';
					}
            	});
            	myMask.show();
            	Ext.Ajax.request({
			        waitMsg:'正在提交....',
			        method:'POST',
			        params:{op:'save',type:'radiogroupvalue',param:x,id:'<{$fld.id}>'},
			        url:'fldcfg.php',
			        success:function(form, action) {
			             myMask.hide();
			             parent.Ext.getCmp('t<{$fld.id}>').close();
			        },
			        failure: function(form, action) {
			        }
			     });
            }
        },{
            text: '重置'
        }]
});

var form = new Ext.form.FormPanel({
		renderTo: Ext.getBody(),
        //frame:true,
		//defaults:{autoScroll: true},
		items:[
			tabpanel
		]
});
var fieldset= Ext.getCmp('fieldset').items.items;
});
</script>
</head>
<body>
</body>
</html>